<template>
	<view class="pages">
		<view class="couponList">
			<view class="item" v-for="(item, index) in couponInfo" :key="index">
				<view class="left">
					<view class="face_value"><text>￥</text>{{item.face_value}}</view>
					<view class="full">满{{item.full}}元可用</view>
				</view>
				<view class="right">
					<view class="title">unclearcare 专享优惠券</view>
					<view class="time">到期时间: {{item.expire_time}}</view>
				</view>
				<label>
					<radio :checked="checked == index ? true : false" color="#000000" :disabled="item.disabled" @click="btnRadio(index,item.face_value,item.id)"></radio>
				</label>
			</view>
		</view>
	</view>
</template>

<script>
	import {HTTP} from '@/pages/http.js';
	let http = new HTTP();
	export default {
		data(){
			return {
				couponInfo: [],
				checked: -1,
				face_value: 0,
				coupon_log_id: ''
			}
		},
		onLoad(e) {
			this.couponInfo = JSON.parse(e.list);
			console.log(e.priceAll);
			this.couponInfo.forEach((value, index)=>{
				if(parseFloat(e.priceAll) >= value.full){
					value.disabled = false
				}else{
					value.disabled = true
				}
			})
			console.log(this.couponInfo);
		},
		methods:{
			btnRadio(index,face_value,id){
				if(this.checked == index){
					this.checked = -1;
					this.face_value = 0;
					this.coupon_log_id = '';
				}else{
					this.checked = index;
					this.face_value = face_value;
					this.coupon_log_id = id
				}
				uni.setStorageSync("face_value", this.face_value);
				uni.setStorageSync("coupon_log_id", this.coupon_log_id);
				
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #f5f5f9;
		height: 100%;
	}
	.pages{
		background-color: #f5f5f9;
		height: 100%;
		.couponList{
			padding: 30upx;
			.item{
				position: relative;
				display: flex;
				width: 100%;
				height: 140upx;
				background: url(https://xx.nikm.cn/upload/coupon_bg.png) no-repeat;
				background-size: 100%;
				margin-bottom: 20upx;
				.left{
					width: 176upx;
					height: 100%;
					color: #fff;
					padding-top: 15upx;
					.face_value{
						font-size: 56upx;
						font-weight: bold;
						text-align: center;
						text{
							font-size: 30upx;
							font-weight: 200;
						}
					}
					.full{
						font-size: 18upx;
						text-align: center;
					}
				}
				.right{
					width: 440upx;
					height: 100%;
					padding: 20upx 0 0 30upx;
					.title{
						font-size: 30upx;
						margin-bottom: 20upx;
					}
					.time{
						font-size: 22upx;
					}
				}
				label{
					position: absolute;
					right: 30upx;
					top: 45upx;
					transform: scale(.8);
				}
			}
		}
	}
</style>
